<?php /* Smarty version Smarty-3.0.6, created on 2018-04-28 09:04:09
         compiled from "/home/user08/dingwei/temp/default/share.htm" */ ?>
<?php /*%%SmartyHeaderCode:17733546745ae3c88985bcf1-64373956%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    '45ea8890b0b7758098c30eb8225586adb796beeb' => 
    array (
      0 => '/home/user08/dingwei/temp/default/share.htm',
      1 => 1524541034,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '17733546745ae3c88985bcf1-64373956',
  'function' => 
  array (
  ),
  'has_nocache_code' => false,
)); /*/%%SmartyHeaderCode%%*/?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="/temp/default/js/jquery-3.1.0.min.js"></script>
    <script src="/temp/default/js/flexible.debug.js"></script>
    <script src="/temp/default/js/flexible_css.debug.js"></script>
    <link rel="stylesheet" href="/temp/default/css/index.css">
    <title>福利大抽奖</title>
</head>
<body>
    <div class="container">
        <p class="label">填写分享信息，吸引好友打开你分享的消息！</p>
        <input type="text" id="title" placeholder="分享标题例如:kaki送你一次免费抽奖活动" />
        <input type="text" id="desc" placeholder="分享的描述,至少6-12个字，越完善越有诱惑性" />
        <p class="label">试试上传一张照片作为分享分享的图标</p>
        <div class="upload">
            <form id="upfile" enctype="multipart/form-data" method="post">
                <input type="file" name="upload_name" id="upload" />
                <img id="img" src="/temp/default/image/upload.png" alt=""/>
                <input type="hidden" id="images" />
            </form>
        </div>
        <p class="infer">
            提示：<br/>
            1、输入分享标题和分享描述即可分享好友，图标不上传默认红包图标<br/>
            2、直接发送好友即可，也可以发送到朋友圈<br/>
            3、默认提供红包分享图标
        </p>
        <p><a href="index.php?action=panel_list&userid=<?php echo $_smarty_tpl->getVariable('userid')->value;?>
">定位列表</a></p>
    </div>
</body>
<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script>
    var appId = '<?php echo $_smarty_tpl->getVariable('signPackage')->value['appId'];?>
';
    var timestamp = '<?php echo $_smarty_tpl->getVariable('signPackage')->value['timestamp'];?>
';
    var nonceStr = '<?php echo $_smarty_tpl->getVariable('signPackage')->value['nonceStr'];?>
';
    var signature = '<?php echo $_smarty_tpl->getVariable('signPackage')->value['signature'];?>
';
    var userid = '<?php echo $_smarty_tpl->getVariable('userid')->value;?>
';
    $("#title").change(function (e){
        share();
    });
    $("#desc").change(function (e) {
        share();
    });
    $("#upload").change(function (e) {
        var file = e.target.files[0];
        var formData = new FormData();
        formData.append("file",file)
        $.ajax({
            url: "api/upload.php",
            type: "POST",
            processData: false,
            contentType: false,
            data: formData,
            success: function(data) {
                data = JSON.parse(data);
                if(data.file_path){
                    $("#img").attr("src", data.file_path);
                    $('#images').val(data.file_path);
                    share();
                }else{
                    alert(data);
                }
            }
        });

    });

    function share(a){
        wx.config({
            debug: false,
            appId: appId,
            timestamp:timestamp,
            nonceStr: nonceStr,
            signature: signature,
            jsApiList: [
                // 所有要调用的 API 都要加到这个列表中
                'onMenuShareTimeline',
                'onMenuShareAppMessage'
            ]
        });
        wx.ready(function(){
            var title = $('#title').val() ;
            var desc = $('#desc').val() ;
            var imgUrl = $('#images').val();
            if(!imgUrl){
                imgUrl = "http://dingwei.famishare.me/temp/default/image/hongbao.png";
            }else{
                imgUrl = "http://dingwei.famishare.me/"+imgUrl;
            }
            wx.onMenuShareTimeline({
                title:title, // 分享标题
                link: 'http://dingwei.famishare.me/panel.php?userid='+userid, // 分享链接
                imgUrl:imgUrl, // 分享图标
                desc:desc,
                success: function () {
                    // 用户确认分享后执行的回调函数
                    //  alert("分享成功");
                },
                cancel: function () {
                    // 用户取消分享后执行的回调函数
                }
            });
            wx.onMenuShareAppMessage({
                title: title,
                desc:desc,
                link: 'http://dingwei.famishare.me/panel.php?userid='+userid, // 分享链接
                imgUrl: imgUrl, // 分享图标
                type: '', // 分享类型,music、video或link，不填默认为link
                dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
                success: function () {
                    // 用户确认分享后执行的回调函数
                    //  alert("分享成功");
                },
                cancel: function () {
                    // 用户取消分享后执行的回调函数
                }
            });
        })
    }

    </script>
</html>